import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

# 创建一个新的图形和子图
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")

# 绘制 3D 线图
x = [1, 2, 3]
y = [4, 5, 6]
z = [7, 8, 9]
ax.plot(x, y, z)

# 绘制 3D 散点图
ax.scatter(x, y, z)

# 绘制 3D 表面图
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(np.sqrt(X**2 + Y**2))
ax.plot_surface(X, Y, Z, cmap="viridis")

plt.show()
